package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.annotation.LoginAnnotation;
import cn.wolfcode.wolf2w.domain.*;
import cn.wolfcode.wolf2w.redis.IRedisService;
import cn.wolfcode.wolf2w.service.*;
import cn.wolfcode.wolf2w.util.JsonResult;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/destinations")
public class DestinationController {
    @Autowired
    private IDestinationService destinationService;
    @Autowired
    private IRegionService regionService;
    @Autowired
    private IStrategyCatalogService strategyCatalogService;
    @Autowired
    private IStrategyService strategyService;


    @GetMapping("hotRegion")
    public Object hotRegion(){
        List<Region> list = regionService.hotRegion(Region.STATE_HOT);
        return JsonResult.success(list);
    }

    @GetMapping("search")
    public Object search(String regionId){
        List<Destination> list = destinationService.searchByRegionId(regionId);
        return JsonResult.success(list);
    }

    /**
     * 导航吐司
     * @param destId
     * @return
     */
    @GetMapping("toasts")
    public Object toasts(String destId){
        List<Destination> list = destinationService.getToasts(destId);
        return JsonResult.success(list);
    }

    /**
     * 概况的攻略分类
     * @param destId
     * @return
     */
    @GetMapping("catalogs")
    public Object catalogs(String destId){
        List<StrategyCatalog> list = strategyCatalogService.getCatalogs(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/strategies/viewnumTop3")
    public Object strategiesViewnumTop3(String destId){
        List<Strategy> list = strategyService.strategiesViewnumTop3(destId);
        return JsonResult.success(list);
    }

    @GetMapping("/travels/viewnumTop3")
    public Object travelsViewnumTop3(String destId){
        List<Travel> list = strategyService.travelsViewnumTop3(destId);
        return JsonResult.success(list);
    }

    @GetMapping("detail")
    public Object detail(String id){
        Destination destinations = destinationService.get(id);
        return JsonResult.success(destinations);
    }
}
